<?php
$bar_active = 'services';
if($_GET['catalias'] == '') {
   $query_cat = '';
   $curr_cat['cat_name'] = 'Dịch vụ điện thoại';
   $seo_meta = get_seo_meta(0,'categories','Dịch vụ điện thoại','');
   $breadcrum_str = '';
}else {
   $curr_cat = db_first('SELECT * FROM categories WHERE cat_alias = "'.$_GET['catalias'].'"');
   if(!$curr_cat) not_found();
   $seo_meta = get_seo_meta($curr_cat['cat_id'],'categories',$curr_cat['cat_name'],'');
   $str_cat = $curr_cat['cat_id'];
   //Neu cat hien tai la cat cha
   if($curr_cat['cat_parent_id'] == 0) {
      $curr_chil_cat = db_array('SELECT * FROM categories WHERE cat_parent_id = '.$curr_cat['cat_id'].'');
      foreach($curr_chil_cat as $chil) {
         $str_cat .= ','.$chil['cat_id'];
      }
      $breadcrum_str = '<span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" class="crumb_item">
                           <a itemprop="url" rel="up" class="crumb" href="'.url_services_cat($curr_cat['cat_alias']).'"><span itemprop="title">'.$curr_cat['cat_name'].'</span></a>
                        </span>';
   }else {
      $curr_parent_cat = db_first('SELECT * FROM categories WHERE cat_id = '.$curr_cat['cat_parent_id'].'');
      $breadcrum_str = '<span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" class="crumb_item">
                           <a itemprop="url" rel="up" class="crumb" href="'.url_services_cat($curr_parent_cat['cat_alias']).'"><span itemprop="title">'.$curr_parent_cat['cat_name'].'</span></a>
                           <span class="arrow"> &gt; </span>
                        </span>
                        <span itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" class="crumb_item">
                           <a itemprop="url" rel="up" class="crumb" href="'.url_services_cat($curr_cat['cat_alias']).'"><span itemprop="title">'.$curr_cat['cat_name'].'</span></a>
                        </span>';
   }
   //Lay ra cac relationship
   $list_relationship = db_array('SELECT DISTINCT rel_service 
                                  FROM relationships_services 
                                  WHERE rel_categories IN('.$str_cat.')');
   $str_service = '0';
   foreach($list_relationship as $value) {
      $str_service .= ','.$value['rel_service'];
   }
   $query_cat = ' AND ser_id IN('.$str_service.')';
}
$list_services = db_array('SELECT * 
                           FROM services
                           WHERE ser_active = 1'.$query_cat.' 
                           LIMIT 20');
$total_products = count($list_services);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi-VN" lang="vi-VN" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <link href="<?=DOMAIN?>/favicon.ico" type="image/x-icon" rel="shortcut icon"/>
   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
   <?php echo $seo_meta;?>
   <!-- css -->
   <link rel="stylesheet" type="text/css" href="/themes/css/base.css"/>
   <link rel="stylesheet" type="text/css" href="/themes/css/service.css"/>
   <link rel="stylesheet" type="text/css" href="/themes/css/mobile.css"/>

   <script type="text/javascript" src="/themes/js/jquery-1.9.0.min.js"></script>
   <script type="text/javascript" src="/themes/js/common.js"></script>
   <script type="text/javascript" src="/themes/js/site.js"></script>
   <?=$facebook_script?>
</head>
<body>
   <?php include 'view/view_header.php'?>
   <?php include 'view/view_services.php'?>
   <?php include 'view/view_support.php'?>
   <?php include 'view/view_footer.php'?>
</body>
</html>